.TH std::experimental::any_cast 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::any_cast \- std::experimental::any_cast

.SH Synopsis
   template<class ValueType>                              \fB(1)\fP (library fundamentals TS)
       ValueType any_cast(const any& operand);
   template<class ValueType>                              \fB(2)\fP (library fundamentals TS)
       ValueType any_cast(any& operand);
   template<class ValueType>                              \fB(3)\fP (library fundamentals TS)
       ValueType any_cast(any&& operand);
   template<class ValueType>
       const ValueType* any_cast(const any* operand)      \fB(4)\fP (library fundamentals TS)
   noexcept;
   template<class ValueType>                              \fB(5)\fP (library fundamentals TS)
       ValueType* any_cast(any* operand) noexcept;

   Performs type-safe access to the contained object.

   For (1-3), the program is ill-formed if ValueType is not a reference and
   std::is_copy_constructible<ValueType>::value is false.

.SH Parameters

   operand - target any object

.SH Return value

   1) Returns
   *any_cast<std::add_const_t<std::remove_reference_t<ValueType>>>(&operand).
   2,3) Returns *any_cast<std::remove_reference_t<ValueType>>(&operand).
   4,5) If operand is not a null pointer, and the typeid of the requested ValueType
   matches that of the contents of operand, a pointer to the value contained by
   operand, otherwise a null pointer.

.SH Exceptions

   1-3) Throws bad_any_cast if the typeid of the requested ValueType does not match
   that of the contents of operand.
.SH Category:
     * Noindexed pages
